import { request } from '@/service/request';
import { SysDictData } from "@/views/system/dict/dict-data/index";

export function fetchData(id: Common.IdType) {
  return request({
    url: `/system/data/${id}`,
    method: 'GET',
  });
}

export function fetchDataListByType(type: string) {
  return request({
    url: `/system/data/list/${type}`,
    method: 'GET',
  });
}

export function fetchAddData(data: SysDictData) {
  return request({
    url: '/system/data/',
    data: data,
    method: 'POST',
  });
}

export function fetchUpdateData(data: SysDictData) {
  return request({
    url: '/system/data/',
    data: data,
    method: 'PUT',
  });
}

export function fetchDelData(ids: Common.IdType[]) {
  // 假设服务器端期望接收逗号分隔的 ID 字符串
  return request({
    url: `/system/data/${ids.join(',')}`,
    method: 'DELETE',
  });
}

